package com.zhixiang.xaec.entity.system;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import com.google.gson.annotations.Expose;

@Entity
@Table(name = "sys_app_function")
public class AppFunction {
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Expose
	protected Long functionId;
	
	protected String funKey;
	
	protected String funName;
	@Transient
	protected Set<FunUrl> funUrls = new HashSet<FunUrl>();
	
	@ManyToOne(optional = true ,cascade = CascadeType.ALL, fetch = FetchType.LAZY )
    @JoinColumn(name = "roleId", referencedColumnName = "roleId")
	protected AppRole appRole;

	public AppFunction() {
	}

	public AppFunction(String paramString1, String paramString2) {
		this.funKey = paramString1;
		this.funName = paramString2;
	}

	public AppFunction(Long paramLong) {
		setFunctionId(paramLong);
	}

	public Set<FunUrl> getFunUrls() {
		return this.funUrls;
	}

	public void setFunUrls(Set<FunUrl> paramSet) {
		this.funUrls = paramSet;
	}

	public Long getFunctionId() {
		return this.functionId;
	}

	public void setFunctionId(Long paramLong) {
		this.functionId = paramLong;
	}

	public String getFunKey() {
		return this.funKey;
	}

	public void setFunKey(String paramString) {
		this.funKey = paramString;
	}

	public String getFunName() {
		return this.funName;
	}

	public void setFunName(String paramString) {
		this.funName = paramString;
	}

	public AppRole getAppRole() {
		return appRole;
	}

	public void setAppRole(AppRole appRole) {
		this.appRole = appRole;
	}

	public boolean equals(Object paramObject) {
		if (!(paramObject instanceof AppFunction))
			return false;
		AppFunction localAppFunction = (AppFunction) paramObject;
		return new EqualsBuilder()
				.append(this.functionId, localAppFunction.functionId)
				.append(this.funKey, localAppFunction.funKey)
				.append(this.funName, localAppFunction.funName).isEquals();
	}

	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.functionId).append(this.funKey)
				.append(this.funName).toHashCode();
	}

	public String toString() {
		return new ToStringBuilder(this).append("functionId", this.functionId)
				.append("funKey", this.funKey).append("funName", this.funName)
				.toString();
	}
}
